package main

import "fmt"

func checkExists(key string, map1 map[string]string) {
	if v, exists := map1[key]; exists {
		fmt.Println("This value exists")
		fmt.Println("value :", v)
	} else {
		fmt.Println("This value doesn't exist")
		fmt.Println("value :", v)
	}
}

func main() {
	map1 := map[string]string{
		"a": "A",
		"b": "B",
		"c": "C",
	}
	checkExists("a", map1)
	fmt.Println("---------------------")
	checkExists("d", map1)
	fmt.Println("---------------------")
	delete(map1, "d")
	fmt.Println(map1)

	if v, exists := map1["d"]; exists {
		fmt.Println("删除 v=", v)
		delete(map1, "d")
		fmt.Println("map1 = ", map1)
	} else {
		fmt.Println("未找到 不执行删除")
	}

	fmt.Println("---------------------")

	if v, exists := map1["c"]; exists {
		fmt.Println("删除 v=", v)
		delete(map1, "c")
		fmt.Println("map1 = ", map1)
	} else {
		fmt.Println("未找到 不执行删除")
	}

}
